package com.syni.mdd.sjb.common.datatreaure.controller.api;

import com.syni.mdd.sjb.common.component.utils.common.utils.ResultMapHelper;
import com.syni.mdd.sjb.common.component.utils.common.utils.RpcResponseVo;
import com.syni.mdd.sjb.common.component.utils.feign.service.mdd.sjb.common.datatreasure.DxshApiBusinessRestService;
import com.syni.mdd.sjb.common.component.utils.feign.service.mdd.commonuser.UserRestService;
import com.syni.mdd.sjb.common.datatreaure.constants.ResultMsg;
import com.syni.mdd.sjb.common.datatreaure.entity.vo.rq.userChannel.BusinessRqVo;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppIndustryService;
import com.syni.mdd.sjb.common.datatreaure.service.DxshAppUserChannelService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/apiAppBusiness")
public class DxshApiBusinessRestApi implements DxshApiBusinessRestService {

    @Autowired
    UserRestService userRestService;

    @Autowired
    DxshAppUserChannelService dxshAppUserChannelService;

    @Autowired
    DxshAppIndustryService dxshAppIndustryService;


    @PostMapping("/getAllBusiness")
    @ApiOperation(value = "第三方调用获取账户下所有店铺信息")
    public Map<String,Object> getAllBusiness(@RequestBody @Validated BusinessRqVo businessRqVo){
        return dxshAppUserChannelService.getAllBusiness(businessRqVo);
    }

    @PostMapping("/userChooseIndustry")
    @ApiOperation(value = "用户选择行业")
    public RpcResponseVo userChooseIndustry(@RequestParam("userId") Integer userId,
                                                 @RequestParam("industryName") String industryName){
        dxshAppIndustryService.chooseIndustry(userId,industryName);
        return RpcResponseVo.success(new HashMap<>(), ResultMsg.HAND_SUCCESS);
    }

    @PostMapping("/userChooseIndustryByIndustryId")
    @ApiOperation(value = "用户选择行业")
    public Map<String,Object> userChooseIndustryByIndustryId(@RequestParam("userId") Integer userId,
                                            @RequestParam("industryId") Integer industryId){
        dxshAppIndustryService.chooseIndustry(userId,industryId);
        return ResultMapHelper.success(new HashMap<>(), ResultMsg.HAND_SUCCESS);
    }
}
